package com.py.credit.controller;


import com.alibaba.fastjson.JSON;

import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.*;
import com.py.credit.service.UploadService;
import com.py.credit.service.UploadXycnService;
import com.py.credit.service.UploadXydService;
import com.py.credit.utils.DateUtil;
import com.py.credit.utils.DateUtils;
import com.py.credit.utils.SMUtils;
import com.py.credit.utils.SubmitConvXmlUtils;
import com.py.framework.core.annotation.IgnoreAuthority;

import com.py.framework.core.log.ExceptionLogger;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.namespace.QName;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "/uploadxycn")
public class UploadXycnController {
    protected int socketTimeout = 30000;// 请求超时时间
    protected int connectTimeout = 30000;// 传输超时时间
    protected String XYCNPostUrl = "https://59.227.152.250:8443/creditdatas/ws/xyjgService?wsdl";
    protected String apiKey = "1FDC0F9843594A168592F6A0AE142E12";
    private final Logger log = LoggerFactory.getLogger(UploadController.class);
    protected String namespace = "com.test.webservices";//命名空间
    protected String XYCNMetohName = "importXycnXml";
    @Autowired
    private UploadXycnService uploadXycnService;

    /**
     * 上传信用承诺
     * 1 法人2 自然人
     */
    @IgnoreAuthority
    @RequestMapping(value = "/uploadXycn.json")
    public RestServiceResult<Object>  uploadXzxk(int type) throws UnsupportedEncodingException {
    	RestServiceResult<Object> result = new RestServiceResult<Object>();

        try {
            Object data = uploadXycnService.execute(apiKey,type,namespace, XYCNPostUrl,  XYCNMetohName);
        	result.setData(data);
			return result;
        } catch (Exception e) {
        	ExceptionLogger.error("UploadController#uploadXycn", "上传信用承诺异常！ERROR：" + e.getMessage(), e);
        	result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("上传信用承诺定时任务异常！");
			return result;
        }

    }


  

   
}
